<?php

namespace Usap\Service\Operation;


class place
{
    public function get_place_config()
    {
        return D("Usap/Common/Places")->getField('place_id,name');
    }


    /**添加场所信息*/
    public function add_place($data)
    {
        $model = D("Usap/Common/Places");
        return $model->add($data);
    }

    /*获取单位列表*/
    public function get_place_list($where)
    {
        $model = D("Usap/Common/Places");
        $count = $model->where($where)->count();
        $list = [];
        if ($count > 0) {
            $list = $model->where($where)->select();
        }
        $result = [
            'count' => $count ? $count : 0,
            'list' => $list
        ];
        return $result;
    }

    /**
     * 获取单位信息
     */
    public function getPlaceByCondition($condition)
    {
        $model = D("Usap/Common/Places");
        return $model->where($condition)->select();
    }

    public function update_place_info($id, $data)
    {
        $model = D("Usap/Common/Places");
        return $model->where(['place_id' => $id])->save($data);
    }

    public function getPlaceInfoById($id)
    {
        return D("Usap/Common/Places")->where(['place_id' => $id])->find();
    }


    public function delete_place_info($id)
    {
        return D("Usap/Common/Places")->where(['place_id' => $id])->delete();
    }


    public function get_place_id()
    {
        return D("Usap/Common/Places")->order('place_id desc')->getField('place_id');
    }
}